/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 26727
 * Date: 2024-07-10
 * Time: 11:33
 */
class Solution1 {
    public boolean lemonadeChange(int[] bills) {
        int five = 0,ten = 0;
        //记录5和10收下的个数
        for(int x : bills) {
            if(x == 5) {
                //5直接收下
                five++;
            }
            else if(x == 10) {
                if(five == 0) {
                    return false;
                }else {
                    five--;
                    ten++;
                }
            }else {
                //贪心:优先选择5和10这种组合
                if(five != 0 && ten != 0) {
                    five--;
                    ten--;
                }
                else if(five >= 3) {
                    five-=3;
                }else {
                    return false;
                }
            }
        }
        return true;
    }
}
